//
//  kWMenuCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 2017/5/25.
//  Copyright © 2017年 EasyToTesco. All rights reserved.
//

#import "kWMenuCell.h"


@interface kWMenuCell()

@property(nonatomic,strong)NSMutableArray *btnArray;
@property(nonatomic,strong)UIButton *selectBtn;

@end


@implementation kWMenuCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self buildSubViews];
    }
    return self;
}


//- (NSArray *)imageName
//{
//    return @[
//             @"kW_Home_menu0",
//             @"kW_Home_menu1",
//             @"kW_Home_menu2",
//             @"kW_Home_menu3"
//             ];
//}
//

- (NSArray *)imageName
{
    return @[
             @"kW_Menu0",
             @"kW_Menu1",
             @"kW_Menu2",
             @"kW_Menu3"
             ];
}

- (NSArray *)title
{
    return @[@"热门推荐",
             @"优秀商家",
             @"话费充值",
             @"油卡充值"
             ];
}


- (void)buildSubViews
{
    
    for (NSInteger i = 0; i < 4; ++i) {
        
        CGFloat HIGH = 85;
        CGRect frame = CGRectMake(i*WIDTH/4,0,WIDTH/4, HIGH);
        
        UIView *menubackView = [[UIView alloc] initWithFrame:frame];
        menubackView.tag = i;
        [self addSubview:menubackView];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(menuBtnclick:)];
        
        [menubackView addGestureRecognizer:tap];
        //图
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.contentMode = UIViewContentModeCenter;
        imageView.image = [UIImage imageNamed:self.imageName[i]];
        [menubackView addSubview:imageView];

        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(menubackView);
            make.width.equalTo(menubackView);
            make.height.mas_equalTo(60);
        }];
        
        //文字
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.font = [UIFont systemFontOfSize:13];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.text = self.title[i];
        titleLabel.textColor = [UIColor grayColor];
        [menubackView addSubview:titleLabel];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(menubackView);
            make.width.equalTo(menubackView);
            make.top.equalTo(imageView.mas_bottom);
        }];
        
        
    }
    
}


- (void)menuBtnclick:(UITapGestureRecognizer *)recognizer
{
    if (self.menuBlock) {
        self.menuBlock(recognizer.view.tag);
    }
}



@end
